<template>
	<view class="Details">
		<app-title text='明细'></app-title>
		<u-empty mode="history" v-if="list.length === 0" icon="http://cdn.uviewui.com/uview/empty/history.png">
		</u-empty>
		<view class="Details_box" v-else>
			<uni-collapse accordion>
				<uni-collapse-item ref="collapseItem" class="Details_box_item" v-for="(item,index) in list" :key="index"
					:title="item.times" :name="index" :shouru="item.shou" :zhichu="item.zhi" :open="true">
					<view class="Details_box_content" v-for="(items,indexs) in item.list" :key="indexs">
						<!-- <view class="Details_box_content_left">
							<image src="@/static/wallet/jinbi.png" mode=""></image>
						</view> -->
						<view class="Details_box_content_right">
							<view class="Details_box_content_right_xiangqing">
								<view class="jieshao">{{items.remark}}</view>
								<view class="time">{{items.time}}</view>
							</view>
							<view class="Details_box_content_right_money">
								<p>{{items.num}}</p>
							</view>
						</view>
					</view>
				</uni-collapse-item>
				<uni-collapse-item ref="collapseItem" :name="index + 1" class="Details_box_item"
					v-for="(item,index) in lists" :key="index + 1" :title="item.times" :shouru="item.shou"
					:zhichu="item.zhi">
					<view class="Details_box_content" v-for="(items,indexs) in item.list" :key="indexs">
						<!-- <view class="Details_box_content_left">
							<image src="@/static/wallet/jinbi.png" mode=""></image>
						</view> -->
						<view class="Details_box_content_right">
							<view class="Details_box_content_right_xiangqing">
								<view class="jieshao">{{items.remark}}</view>
								<view class="time">{{items.time}}</view>
							</view>
							<view class="Details_box_content_right_money">
								<p>{{items.num}}</p>
							</view>
						</view>
					</view>
				</uni-collapse-item>
			</uni-collapse>
		</view>
	</view>
</template>

<script>
	import {
		api_index_new_mingxi_list,
		api_index_new_mingxi_list_teshu
	} from '@/api/wallet.js';
	export default {
		data() {
			return {
				openid: '',
				e: '',
				list: [],
				lists: []

			};
		},
		onLoad(e) {
			this.e = e;
			uni.getStorage({
				key: 'openid',
				success: (res) => {
					this.openid = res.data;
					this.api_index_new_mingxi_listFun();
				},
				fail: () => {
					uni.reLaunch({
						url: '/pages/login/login'
					});
				}
			});
		},
		methods: {
			async api_index_new_mingxi_listFun() {

				this.list = [];
				this.lists = [];



				let up = {
					openid: this.openid,
					type: this.e.type
				}
				let data = null;
				if (this.e.type === "11" || this.e.type === "12" || this.e.type === "13") {
					data = await api_index_new_mingxi_list_teshu(up);
				} else {
					data = await api_index_new_mingxi_list(up);
				}


				if (data.error === 0) {
					console.log(data.arr);
					data.arr.forEach((item, index) => {
						console.log(item);
						if (index === 0) {
							this.list.push(item);
						} else {
							this.lists.push(item);
						}
					})
				}
			},
			backFun() {
				uni.navigateBack({
					delta: 1
				})
			}
		}
	}
</script>

<style lang="scss">
	.Details {
		width: 100%;
		height: 100vh;
		display: flex;
		flex-direction: column;

		.Details_box {
			width: 100%;
			flex: 1;
			overflow-y: auto;

			.Details_box_item {
				width: 100%;
				background-color: #F6F6F6;

				.Details_box_content {
					width: 100%;
					height: 120rpx;
					display: flex;
					align-items: center;
					background-color: #fff;


					.Details_box_content_left {
						width: 120rpx;
						height: 100rpx;

						image {
							width: 100rpx;
							height: 100rpx;
							margin: 0 10rpx;
						}
					}

					.Details_box_content_right {
						flex: 1;
						height: 100%;
						border-bottom: 1rpx solid #F6F6F6;
						display: flex;
						justify-content: space-between;
						padding: 0 30rpx;
						align-items: center;

						.Details_box_content_right_xiangqing {
							display: flex;
							flex-direction: column;
							justify-content: space-around;
							height: 100rpx;

							.jieshao {
								font-size: 29rpx;
								color: #333;
							}

							.time {
								font-size: 25rpx;
								color: #B5B5B5;
							}
						}

						.Details_box_content_right_money {
							color: #333;
							display: flex;
							align-items: self-end;
							font-size: 26rpx;

							p {
								font-size: 40rpx;
							}
						}
					}
				}
			}

		}
	}
</style>